<template>
  <div></div>
</template>

<script setup lang="ts">
import { ref, inject, computed, watch, onMounted, onBeforeUnmount } from 'vue';
import { useUserStore } from '@/store/user';

defineOptions({
  name: 'LinkLayer'
})

// interface LayerItem {
//   type: string;
//   code: string;
//   url: string;
//   properties?: string;
// }

// interface PropsType {
//   layerData: LayerItem
// }
const userStore = useUserStore()

// const props = withDefaults(defineProps<PropsType>(), {})

layerData: () => {
  return null
}

const main = inject<any>('main');
const { mapInstance }: any = main;

let layer: any;

// 增加wms图层
// const addWmsLayer = async () => {
//   if (mapInstance.value){
//     await mapInstance.value.acApi.camera.set(536491.8625, 2510202.08, 1000, -83.974602, -114.262474)
//     userStore.setShowLayer2In(true)
//     layer = await mapInstance.value.mapClass.LayerClass.addWmsLayer([props.layerData])
//   }
// }

// // 删除wms图层
// const clearWmsLayer = () => {
//   if (mapInstance.value){
//     mapInstance.value.mapClass.LayerClass.removeWmsLayer([props.layerData])
//   }
// }


// 路段态势监测=====》 搜索车牌
const linkSearchShow = computed(() => {
  return userStore.getLinkSearchShow
})
// 路段态势监测 ======》 第一/第三视角
const shijiaoShow = computed(() => {
  return userStore.getShijiaoShow
})
// 路段态势监测 ======》 三急按钮
const sjShow = computed(() => {
  return userStore.getSJShow
})

// 监听进入路段态势后，显示对应搜索车牌、第一三人称、三急按钮
// watch()

// 监听index页面是否显示路况图层
// watch(() => props.visible, (newVal) => {
//   if (newVal) {
//     mapInstance.value.acApi.polyline.show()
//   } else {
//     mapInstance.value.acApi.polyline.hide()
//   }
// })

onMounted(() => {
  // addWmsLayer()
  userStore.setShowLayer2In(true)
  userStore.setLinkSearchShow(true)
})

onBeforeUnmount(() => {
  // clearWmsLayer()
  userStore.setShowLayer2In(false)
  try {
    layer.closePopup && layer.closePopup()
  } catch (error) {}
})
</script>

<style lang="less" scoped></style>